package swingFiles;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Font;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.SQLException;

/**
 * Creates the panel for the managers of the gym management system.
 * 
 * @author Emily Linniman
 * @version December 1, 2014
 *
 */
@SuppressWarnings("serial")
public class ManagerHome extends JPanel {

	/** The frame on which the panel is placed on. */
	private JFrame my_frame;

	/**
	 * Creates the panel
	 * @param the_frame the frame the panel is placed on
	 */
	public ManagerHome(JFrame the_frame) {
		my_frame = the_frame;
		my_frame.setTitle("Manager");
		final JPanel currentPanel = this;
		
		setBackground(Color.ORANGE);
		my_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		setLayout(null);
		
		JLabel lblWelcomeManager = new JLabel("Welcome, Manager!");
		lblWelcomeManager.setBounds(159, 0, 161, 22);
		lblWelcomeManager.setHorizontalAlignment(SwingConstants.CENTER);
		lblWelcomeManager.setFont(new Font("Arial", Font.PLAIN, 18));
			add(lblWelcomeManager);
		
		JButton createClassButton = new JButton("Create a Class");
		createClassButton.setBounds(27, 61, 172, 29);
		createClassButton.setFont(new Font("Arial", Font.PLAIN, 15));
		createClassButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try {
					my_frame.setContentPane(new CreateClassPanel(my_frame, currentPanel));
					my_frame.validate();
					my_frame.setVisible(true);
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		});
		add(createClassButton);
		
		JButton cancelClassButton = new JButton("Cancel Class");
		cancelClassButton.setBounds(27, 174, 172, 29);
		cancelClassButton.setFont(new Font("Arial", Font.PLAIN, 15));
		cancelClassButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				my_frame.setContentPane(new cancelClassPanel(my_frame, currentPanel));
				my_frame.validate();
				my_frame.setVisible(true);
			}
		});
		add(cancelClassButton);
		
		JButton registerMemberButton = new JButton("Register Member");
		registerMemberButton.setBounds(260, 61, 156, 29);
		registerMemberButton.setFont(new Font("Arial", Font.PLAIN, 15));
		add(registerMemberButton);
		
		JButton addMemberButton = new JButton("Add Member to Class");
		addMemberButton.setBounds(27, 229, 172, 29);
		addMemberButton.setFont(new Font("Arial", Font.PLAIN, 15));
		add(addMemberButton);
		
		JButton hireInstructorButton = new JButton("Hire Instructor");
		hireInstructorButton.setBounds(260, 115, 156, 29);
		hireInstructorButton.setFont(new Font("Arial", Font.PLAIN, 15));
		add(hireInstructorButton);
		
		JButton hireStaffButton = new JButton("Hire Staff");
		hireStaffButton.setBounds(260, 174, 156, 29);
		hireStaffButton.setFont(new Font("Arial", Font.PLAIN, 15));
		add(hireStaffButton);
		
		JButton editClassButton = new JButton("Edit Class");
		editClassButton.setBounds(27, 115, 172, 29);
		editClassButton.setFont(new Font("Arial", Font.PLAIN, 15));
		editClassButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				my_frame.setContentPane(new EditClassPanel(my_frame, currentPanel));
				my_frame.validate();
				my_frame.setVisible(true);
			}
		});
		add(editClassButton);
		
		JButton logoutButton = new JButton("Logout");
		logoutButton.setBounds(260, 229, 156, 29);
		logoutButton.setFont(new Font("Arial", Font.PLAIN, 15));
		logoutButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				my_frame.setContentPane(new LogIn(my_frame));
				my_frame.validate();
				my_frame.setVisible(true);
			}
		});
		add(logoutButton);
	}

}
